namespace ::


type Post record {
    PostId String,
    Author String,
    Time   String,
    Text   String
}
const FakeData List[Post] {
    List(
        new Post('1001', 'Foo', '1 hr ago',  'The quick brown fox jumps over lazy dog.'),
        new Post('1002', 'Bar', '4 min ago', 'Whatever.'),
        new Post('1003', 'Foo', '3 min ago', 'Lorem ipsum dolor sit amet.'),
        new Post('1004', 'ABC', '2 min ago', 'consectetur adipiscing elit.'),
        new Post('1005', 'DEF', '1 min ago', 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'),
        new Post('1006', 'Foo', 'just now',  'OK.'),
        new Post('1007', '???', 'just now',  'looongWord1a2b3c4d5e2309fg3ngvoi3wqg3r5hj466tereh5jnyfegrhtjhtgfdrfg5ht6jhrioeb')
    )
}

entry {
    ShowWindow({
        let data = FakeData,
        @use items = Hooks((data map { post => {
            @use avatar = IconLabel(Icon('qt-logo')),
            @use author = Label($(String('@',post.Author)), Left, Yes),
            @use time = Label($(post.Time)),
            @use text = TextView($(post.Text)),
            let top = Row(Row(avatar.Widget, author.Widget), Spacer(), time.Widget),
            let bottom = Row(text.Widget),
            @use wrapper = WrapperWithMargins(Column(top, bottom)),
            // @use wrapper = WrapperWithMargins { layout: Column(top, bottom), policy-y: Bounded },
            Hook[LayoutItem](wrapper.Widget)
        }})),
        @use area = ScrollAreaWithMargins(VerticalOnly, Column(Column{items}, Spacer()), 2, 4),
        // @use area = ScrollArea(VerticalOnly, Column { items: ListConcat(views, List(Spacer())) }),
        Window($('Posts'), Column(area.Widget))
    })
}


